@echo off
chcp 65001 >nul
title 修复点云融合项目环境

echo ========================================
echo 🔧 修复点云融合项目环境
echo ========================================
echo.

echo 🔄 激活pointcloud_fusion环境...
call conda activate pointcloud_fusion

echo.
echo 📦 配置国内镜像源...
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip config set global.trusted-host pypi.tuna.tsinghua.edu.cn

echo.
echo 📦 安装依赖包（使用国内镜像）...
pip install flask flask-cors opencv-python numpy matplotlib -i https://pypi.tuna.tsinghua.edu.cn/simple

echo.
echo 🧪 验证安装...
python -c "import flask, cv2, numpy, matplotlib; print('✅ 所有依赖包安装成功')"

if errorlevel 1 (
    echo ❌ 依赖验证失败，尝试备用方案...
    echo.
    echo 📦 尝试使用豆瓣镜像...
    pip install flask flask-cors opencv-python numpy matplotlib -i https://pypi.douban.com/simple/
    
    echo.
    echo 🧪 再次验证安装...
    python -c "import flask, cv2, numpy, matplotlib; print('✅ 所有依赖包安装成功')"
    
    if errorlevel 1 (
        echo ❌ 安装仍然失败，请检查网络连接
        pause
        exit /b 1
    )
)

echo.
echo ✅ 环境修复完成！
echo.
echo 💡 接下来可以启动项目:
echo 1. conda activate pointcloud_fusion
echo 2. cd backend
echo 3. python backend_api.py
echo.
pause
